package com.xquant.marketdata.marketdata.controller;

import com.github.pagehelper.PageInfo;
import com.xquant.marketdata.marketdata.service.TirService;
import com.xquant.marketdata.utils.CommResponse;
import com.xquant.marketdata.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 利率
 * newCloud
 *
 * @author ershuai.zhao
 */
@RestController
@RequestMapping("tirController")
public class TirController {

    @Autowired
    private TirService tirService;

    /**
     * 查询 债券信息
     */
    @ResponseBody
    @RequestMapping(value = "/queryTirInfoByPage.action")
    public PageInfo<Map> queryTirInfoByPage(@RequestParam Map<String, Object> param) {
        PageInfo<Map> pageInfo = tirService.queryTirInfoByPage(param);
        return pageInfo;
    }

    /**
     * 查询 债券分红
     */
    @ResponseBody
    @RequestMapping(value = "/queryTirPriceByPage.action")
    public PageInfo<Map> queryTirPriceByPageByPage(@RequestParam Map<String, Object> param) {
        PageInfo<Map> pageInfo = tirService.queryTirPriceByPage(param);
        return pageInfo;
    }

    /**
     * 查询
     */
    @ResponseBody
    @RequestMapping(value = "/queryTirPriceList.action")
    public CommResponse queryTirPriceList(@RequestParam Map<String, Object> param) {
        String endDate = DateUtils.getCurr_YYYY_MM_DD();
        String begDate = DateUtils.getCalculateDate(endDate, -7);
        param.put("begDates", begDate);
        param.put("endDates", endDate);
        List<Map> list = tirService.queryTirPriceList(param);
        return new CommResponse(true, list);
    }


}
